CSS 属性

属性 line-break 对于确定如何在文本块中换行很有用。这是至关重要的,因为它使页面更清晰易读。

属性值

  • auto:应用默认换行规则。

属性值

  • auto:应用默认换行规则。

  • loose:应用最少限制的换行规则。

  • normal:应用最常见的换行规则。

  • strict:应用最严格的换行规则。

  • anywhere:允许浏览器在任何位置、任何字符处应用换行规则。

  • initial:设置初始值。

  • inherit:继承父元素的值。

适用范围

所有 HTML 元素。

DOM 语法

object.style.lineBreak = "strict"; 

示例

这里是一个示例:

 <html>
<head>
<style>
   p {
      border: 2px solid blue;
      width: 200px;
   }
   .normal {
      line-break: normal;
   }
   .loose {
      line-break: loose;
   }
   .strict {
      line-break: strict;
   }
   .auto {
      line-break: auto;
   }
   .anywhere {
      line-break: anywhere;
   }
</style>
</head>
<body>
   <h2>Line Break</h2>
      <p class="normal">Normal: CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text.</p>
      <p class="loose">Loose: CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
      <p class="strict">Strict: CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
      <p class="auto">Auto: CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
      <p class="anywhere">Anywhere: CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
</body>
</html>